//
//  CZHomeTableViewcontroller.m
//  CZOC微博01
//
//  Created by 1 on 15/11/23.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "CZHomeTableViewcontroller.h"
#import "CZDropDownMenu.h"
#import "CZPullTableViewController.h"
@interface CZHomeTableViewcontroller ()<CZDropDelegate>
//@property (nonatomic,strong) UIImageView *contentView;
@end

@implementation CZHomeTableViewcontroller

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *titleBtn=[[UIButton alloc] init];
    
    titleBtn.width=100;
    titleBtn.height=30;
//    titleBtn.backgroundColor=[UIColor redColor];
    [titleBtn setImage:[UIImage imageNamed:@"navigationbar_arrow_up"]forState:UIControlStateNormal];
     
    [titleBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [titleBtn setTitle:@"首页 " forState:UIControlStateNormal];
    //通过这种方法也可以设置
    titleBtn.imageEdgeInsets=UIEdgeInsetsMake(0, 60, 0, 0);
    titleBtn.titleEdgeInsets=UIEdgeInsetsMake(0, 0, 0, 50);
    self.navigationItem.titleView=titleBtn;
  
    //监听按钮的点击
    [titleBtn addTarget:self action:@selector(titleBtn:) forControlEvents:UIControlEventTouchUpInside];
    
     //text
//    UIButton *btn=[[UIButton alloc]init];
//    btn.frame=CGRectMake(50, 50, 100, 50);
//    btn.backgroundColor=[UIColor redColor];
//    [btn addTarget:self action:@selector(titleBtn:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:btn];
//    
    
    
}



- (void)titleBtn:(UIButton *)btn
{
    [btn setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    CZDropDownMenu *dropView=[CZDropDownMenu menu];
    dropView.delegate=self;
//    dropView.content=[[UITableView alloc]init];
//    dropView.content=[UIButton buttonWithType:UIButtonTypeContactAdd];
//    dropView.content =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 200)];
    CZPullTableViewController *pullView=[[CZPullTableViewController alloc]init];
    pullView.view.height=200;
    
    dropView.controller=pullView;
    
    [dropView show:btn];
    
//    [[NSNotificationCenter defaultCenter] postNotificationName:@"pullChange" object:self userInfo:nil];
    
    
    
    
}
//实现它的代理方法
- (void)dorpDownMenuDismiss:(CZDropDownMenu *)dropDownMenu
{
  UIButton *pullBtn=(UIButton *)self.navigationItem.titleView;
    
    [pullBtn setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateNormal];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
